package Num4;

public class Solution {
    public static int removeDuplicates(int[] nums) {
        int usedSize=1;//先计入nums[0]
        for (int i = 1; i < nums.length; i++) {
                if(nums[i]!=nums[i-1]){
                    usedSize++;
                    nums[i-1]=nums[i];
                }

        }
        return usedSize;
    }
    public static void main(String[] args) {
        int[] nums={1,2,3,4,4,5,5,6,7};
        System.out.println(removeDuplicates(nums));
    }

}

